<template>
  <div class="survey-box">
    <el-row type="flex" justify="space-between" align="middle" class="survey-hedaer">
      <div class="title">流量看板</div>
      <el-link v-if="linkUrl != ''" :underline="false" type="primary" @click="$router.push({ path: linkUrl })">查看详情</el-link>
      <card-header v-else title="" @change="changeOrderTime" />
    </el-row>
    <el-row class="survey-body" :gutter="50">
      <el-col :span="18">
        <visit />
      </el-col>
      <el-col :span="6">
        <div class="survey-contnet">
          <div class="title">访问量(PV)</div>
          <div class="num">
            <count-roll :number="response.pv" />
          </div>
          <el-row type="flex" justify="start">
            <div>日环比: {{ response.pv_ratio || 0 | floatSymbol | preSymbol }}</div>
            <div>周同比: {{ response.pv_week_ratio || 0 | floatSymbol | preSymbol }}</div>
          </el-row>
        </div>
        <div class="survey-contnet">
          <div class="title">独立访客数(UV)</div>
          <div class="num">
            <count-roll :number="response.uv" />
          </div>
          <el-row type="flex" justify="start">
            <div>日环比: {{ response.uv_ratio || 0 | floatSymbol | preSymbol }}</div>
            <div>周同比: {{ response.uv_week_ratio || 0 | floatSymbol | preSymbol }}</div>
          </el-row>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import CardHeader from '../../card/card_header.vue';
import Visit from './components/visit.vue';
import CountRoll from '@/pages/data/components/count_roll';
export default {
  components: {
    CardHeader,
    Visit,
    CountRoll
  },
  props: {
    // 指定跳转链接,右侧为查看详情按钮,否则为时间选择
    // 暂未时间按时间选择展示数据
    linkUrl: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      response: {}
    };
  },
  created() {
    this.$http.get(
      '/admin/data/survey/today/flow',
      {},
      response => {
        this.response = response.data;
      },
      errror => { },
      false
    );
  },
  methods: {
    changeOrderTime: function (time) { }
  }
};
</script>

<style scoped lang="scss">
.survey-box {
  background-color: #fff;
  min-height: 150px;
  margin-bottom: 20px;
  padding: 10px 20px 25px;
  .survey-hedaer {
    margin-bottom: 28px;
    height: 36px;
    padding-right: 20px;
    background-color: #f1f8ff;
    .title {
      color: #303133;
      font-size: 15px;
      padding-left: 6px;
      border-left: 2px solid #5191ff;
    }
  }
  .survey-contnet {
    margin-top: 30px;
    padding: 18px 32px 26px;
    box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(220, 223, 230, 1);
    .title {
      color: #606266;
      font-size: 14px;
      margin-bottom: 15px;
    }
    .num {
      font-size: 22px;
      font-weight: bold;
      color: #303133;
      margin-bottom: 22px;
    }
    .ratio {
      color: #303133;
      font-size: 12px;
      & + .ratio {
        margin-left: 60px;
      }
    }
  }
}
</style>
